package top.v5it.japi.plus.example.jpa.controller;

import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import top.v5it.japi.plus.core.spring.web.JapiEada;
import top.v5it.japi.plus.support.limit.JapiLimit;

import java.time.LocalDate;

/**
 * 示例接口
 *
 * @author zhanpu
 * @date 2022/6/20
 */
@Slf4j
@RestController
@RequestMapping("/v1/example")
public class ExampleController {

//    @JapiLimit(limit = 1, time = 15)
//    @JapiEada(isEncrypt = false)
//    @GetMapping("{id}/{resource}")
//    public void testDecrypt(@PathVariable("id") Integer id, @PathVariable("resource") String resource) {
//
//        log.info("id[{}]", id);
//        log.info("resource[{}]", resource);
//    }

    @JapiEada(isDecrypt = false)
    @GetMapping("{id}/{name}")
    public TestExampleDTO testEncrypt(@PathVariable("id") Integer id, @PathVariable("name") String name) {

        log.info("id[{}]", id);

        TestExampleDTO.Resource resource = new TestExampleDTO.Resource()
                .setTel("18589023487")
                .setIdNum("430682176523908729");

        return new TestExampleDTO()
                .setBirthday(LocalDate.parse("1999-12-20"))
                .setId(1L)
                .setName("zhangshan")
                .setSex("男")
                .setResource(resource);
    }
}
